package com.atguigu.json;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.atguigu.bean.OrderInfo;
//import com.atguigu.bean.OrderInfor2;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author WangJX
 * @version 1.0
 * @date 2019/11/30 0:28
 */
public class JsonUtils {

//    public static String getBeanJson(OrderInfor2 object) {
//        String jsonString = JSON.toJSONString(object);
//        return jsonString;
//    }


    public static String getBeanJson(Object object) {
        String jsonString = JSON.toJSONString(object);
        return jsonString;
    }

    public static void beanTojson() {
        Data data = new Data();
        data.setAction("add");
        data.setId("1");
        data.setOrdinal(8L);
        data.setOrganUnitFullName("testJSON");data.setParent("0");data.setSuborderNo("58961");

        String s = JSON.toJSONString(data);
        System.out.println("toJsonString()方法：s=" + s);
    }

    public static void main(String[] args) {
//        beanTojson();


        List list = new ArrayList();
        OrderInfo orderInfor2 = new OrderInfo("1",
                "22",
                "213",
                "214",
                "1244",
                "4314",
                "32552",
                "235235",
                "25235",
                214.0,
                "asafsa1",
                "asfawf",
                "asgaefg",
                "asgag",
                "sagaegag",
                "asgaga",
                "asgasgag",
                "safasg",
                "sagg",
                "safgasgf",
                12,
                213);

//        list.add(orderInfor2);
        System.out.println(JSON.toJSONString(list, new SerializeConfig(true)));

    }

}


class Data implements Serializable {
    private static final long serialVersionUID = -6957361951748382519L;
    private String id;
    private String suborderNo;
    private String organUnitType;
    private String action;
    private String parent;
    private String organUnitFullName;
    private Long ordinal;

    public void setId(String id) {
        this.id = id;
    }

    public void setSuborderNo(String suborderNo) {
        this.suborderNo = suborderNo;
    }

    public void setOrganUnitType(String organUnitType) {
        this.organUnitType = organUnitType;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    public void setOrganUnitFullName(String organUnitFullName) {
        this.organUnitFullName = organUnitFullName;
    }

    public void setOrdinal(Long ordinal) {
        this.ordinal = ordinal;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getId() {
        return id;
    }

    public String getSuborderNo() {
        return suborderNo;
    }

    public String getOrganUnitType() {
        return organUnitType;
    }

    public String getAction() {
        return action;
    }

    public String getParent() {
        return parent;
    }

    public String getOrganUnitFullName() {
        return organUnitFullName;
    }

    public Long getOrdinal() {
        return ordinal;
    }
}
